package com.namo.cchapi.config;

import com.baidu.aip.face.AipFace;
import com.baidu.aip.ocr.AipOcr;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;


/**
 * @author WangXin
 * @date 2021/3/31 15:38
 */
@Configuration
@RefreshScope
public class BaiduAiConfig {
    /**
     * 人脸识别
     */
    @Value("${baidu.face.app-id}")
    private  String FACE_APP_ID;
    @Value("${baidu.face.api-key}")
    private  String FACE_API_KEY;
    @Value("${baidu.face.secret-key}")
    private  String FACE_SECRET_KEY;

    /**
     *OCR
     */
    @Value("${baidu.ocr.app-id}")
    private  String OCR_APP_ID;
    @Value("${baidu.ocr.api-key}")
    private  String OCR_API_KEY;
    @Value("${baidu.ocr.secret-key}")
    private  String OCR_SECRET_KEY;

    @Autowired
    RestTemplate restTemplate;

    @Bean
    public AipFace ApiFace() {
        // 初始化一个AipFace
        AipFace client = new AipFace(FACE_APP_ID, FACE_API_KEY, FACE_SECRET_KEY);
        return client;
    }

    @Bean
    public AipOcr AipOcr(){
        //初始化ocr
        AipOcr aipOcr = new AipOcr(OCR_APP_ID,OCR_API_KEY,OCR_SECRET_KEY);
        return aipOcr;
    }
}